(function(){"use strict";BX.namespace("BX.Grid");BX.Grid.Data=function(t){this.parent=t;this.reset()};BX.Grid.Data.prototype.reset=function(){this.response=null;this.xhr=null;this.headRows=null;this.bodyRows=null;this.footRows=null;this.moreButton=null;this.pagination=null;this.counterDisplayed=null;this.counterSelected=null;this.counterTotal=null;this.limit=null;this.actionPanel=null;this.rowsByParentId={};this.rowById={};this.isValidResponse=null};BX.Grid.Data.prototype.getParent=function(){return this.parent};BX.Grid.Data.prototype.validateResponse=function(){if(!BX.type.isBoolean(this.isValidResponse)){this.isValidResponse=!!this.getResponse()&&!!BX.Grid.Utils.getByClass(this.getResponse(),this.getParent().settings.get("classContainer"),true)}return this.isValidResponse};BX.Grid.Data.prototype.request=function(t,e,s,i,r,a){if(!BX.type.isString(t)){t=""}if(!BX.type.isNotEmptyString(e)){e="GET"}if(!BX.type.isPlainObject(s)){s={}}var n={gridId:this.parent.getId(),url:t,method:e,data:s};this.parent.disableCheckAllCheckboxes();BX.onCustomEvent(window,"Grid::beforeRequest",[this,n]);if(n.hasOwnProperty("cancelRequest")&&n.cancelRequest===true){return}t=n.url;if(!BX.type.isNotEmptyString(t)){t=this.parent.baseUrl}t=BX.Grid.Utils.addUrlParams(t,{sessid:BX.bitrix_sessid(),internal:"true",grid_id:this.parent.getId()});if("apply_filter"in s&&s.apply_filter==="Y"){t=BX.Grid.Utils.addUrlParams(t,{apply_filter:"Y"})}else{t=BX.util.remove_url_param(t,"apply_filter")}if("clear_nav"in s&&s.clear_nav==="Y"){t=BX.Grid.Utils.addUrlParams(t,{clear_nav:"Y"})}else{t=BX.util.remove_url_param(t,"clear_nav")}t=BX.Grid.Utils.addUrlParams(t,{grid_action:i||"showpage"});e=n.method;s=n.data;this.reset();var o=this;setTimeout(function(){var n=BX.Http.Data.convertObjectToFormData(s);var l=BX.ajax({url:BX.Grid.Utils.ajaxUrl(t,o.getParent().getAjaxId()),data:n,method:e,dataType:"html",headers:[{name:"X-Ajax-Grid-UID",value:o.getParent().getAjaxId()},{name:"X-Ajax-Grid-Req",value:JSON.stringify({action:i||"showpage"})}],processData:true,scriptsRunFirst:false,start:false,preparePost:false,onsuccess:function(t){o.response=BX.create("div",{html:t});o.response=o.response.querySelector("#"+o.parent.getContainerId());o.xhr=l;if(o.parent.getParam("HANDLE_RESPONSE_ERRORS")){var e;try{e=JSON.parse(t)}catch(t){e={messages:[]}}if(e.messages.length){o.parent.arParams["MESSAGES"]=e.messages;o.parent.messages.show();o.parent.tableUnfade();return}}if(BX.type.isFunction(r)){o.parent.enableCheckAllCheckboxes();BX.delegate(r,o)(t,l)}},onerror:function(t){o.error=a;o.xhr=l;if(BX.type.isFunction(a)){o.parent.enableCheckAllCheckboxes();BX.delegate(a,o)(l,t)}}});l.send(n)},0)};BX.Grid.Data.prototype.getResponse=function(){return this.response};BX.Grid.Data.prototype.getHeadRows=function(){if(!this.headRows){this.headRows=BX.Grid.Utils.getByClass(this.getResponse(),this.getParent().settings.get("classHeadRow"))}return this.headRows};BX.Grid.Data.prototype.getBodyRows=function(){if(!this.bodyRows){this.bodyRows=BX.Grid.Utils.getByClass(this.getResponse(),this.getParent().settings.get("classBodyRow"))}return this.bodyRows};BX.Grid.Data.prototype.getRowsByParentId=function(t){if(!(t in this.rowsByParentId)){this.rowsByParentId[t]=BX.Grid.Utils.getBySelector(this.getResponse(),"."+this.getParent().settings.get("classBodyRow")+'[data-parent-id="'+t+'"]')}return this.rowsByParentId[t]};BX.Grid.Data.prototype.getRowById=function(t){if(!(t in this.rowById)){this.rowById[t]=BX.Grid.Utils.getBySelector(this.getResponse(),"."+this.getParent().settings.get("classBodyRow")+'[data-id="'+t+'"]',true)}return this.rowById[t]};BX.Grid.Data.prototype.getFootRows=function(){if(!this.footRows){this.footRows=BX.Grid.Utils.getByClass(this.getResponse(),this.getParent().settings.get("classFootRow"))}return this.footRows};BX.Grid.Data.prototype.getMoreButton=function(){if(!this.moreButton){this.moreButton=BX.Grid.Utils.getByClass(this.getResponse(),this.getParent().settings.get("classMoreButton"),true)}return this.moreButton};BX.Grid.Data.prototype.getPagination=function(){if(!this.pagination){this.pagination=BX.Grid.Utils.getByClass(this.getResponse(),this.getParent().settings.get("classPagination"),true);if(BX.type.isDomNode(this.pagination)){this.pagination=BX.firstChild(this.pagination)}}return this.pagination};BX.Grid.Data.prototype.getCounterDisplayed=function(){if(!this.counterDisplayed){this.counterDisplayed=BX.Grid.Utils.getByClass(this.getResponse(),this.getParent().settings.get("classCounterDisplayed"),true)}return this.counterDisplayed};BX.Grid.Data.prototype.getCounterSelected=function(){if(!this.counterSelected){this.counterSelected=BX.Grid.Utils.getByClass(this.getResponse(),this.getParent().settings.get("classCounterSelected"),true)}return this.counterSelected};BX.Grid.Data.prototype.getCounterTotal=function(){if(!BX.type.isDomNode(this.counterTotal)){var t="."+this.getParent().settings.get("classCounterTotal")+" ."+this.getParent().settings.get("classPanelCellContent");this.counterTotal=BX.Grid.Utils.getBySelector(this.getResponse(),t,true)}return this.counterTotal};BX.Grid.Data.prototype.getLimit=function(){if(!this.limit){this.limit=BX.Grid.Utils.getByClass(this.getResponse(),this.getParent().settings.get("classPageSize"),true)}return this.limit};BX.Grid.Data.prototype.getPageSize=function(){return this.getLimit()};BX.Grid.Data.prototype.getActionPanel=function(){if(!this.actionPanel){this.actionPanel=BX.Grid.Utils.getByClass(this.getResponse(),this.getParent().settings.get("classActionPanel"),true)}return this.actionPanel}})();
//# sourceMappingURL=data.map.js